package com.mowuju.data.jike.rpc;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.ipc.RPC;

import java.io.IOException;

/**
 * @author liumo yangqiuhua@xincheng818.com
 * @project: mapreduce
 * @description:
 * @date 2021/7/25
 */
public class RpcServer {
    private void init() {
        Configuration configuration = new Configuration();
        RPC.Builder builder = new RPC.Builder(configuration);

        builder.setBindAddress("localhost");
        builder.setPort(7021);

        builder.setProtocol(PersonProtocol.class);
        builder.setInstance(new PersonProtocolImpl());

        try {
            RPC.Server server = builder.build();
            server.start();

            System.out.println("server is start");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void main(String ...argv) {
        RpcServer server = new RpcServer();
        server.init();
    }
}
